package pta;/**
 * @author： li
 * @date： 2022-03-31 17:08
 * @version 1.0
 */
import  java.util.*;
public class 划拳 {
    public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int jl_1=sc.nextInt();
    int jl_2=sc.nextInt();
    int n =sc.nextInt();
    int jl_11=0;
    int jl_22=0;
    while(n>0){
        int jhan=sc.nextInt();int jhua = sc.nextInt();
        int yhan=sc.nextInt();int yhua = sc.nextInt();
        int sum = jhan+yhan;
        //同赢||同输 下一轮 不罚
        if(sum==jhua&&sum!=yhua) {
            jl_1--;
            jl_11++;
            if (jl_1<0)
                break;
        }
        if(sum==yhua&&sum!=jhua){
            jl_2--;
            jl_22++;
        if(jl_2<0)
            break;
        }
        n--;
    }
        if(jl_1<0){
            System.out.println("A");
            System.out.println(jl_22);
        }
        if(jl_2<0){
            System.out.println("B");
            System.out.println(jl_11);
        }

    }
}
